'''
Created on Oct 20, 2012

@author: peng
'''
import os
import happybase

connection = happybase.Connection('119.254.86.77',
                                  compat='0.90',
                                  table_prefix='beluga_analysis',
                                  autoconnect=False)
connection.open()

tables = connection.tables()
print tables
table = connection.table('release_date')

root_path = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(root_path, 'release_date_zh')
f = open(file_path)

b = table.batch()
for line in f.readlines():
    values = line.replace('\n', '').split('\t')
    k = '\t'.join(values[:2])
    v = values[2]
    b.put(k, {'value:date': v})

b.send()

connection.close()
